package com.yequan.work;

import java.util.*;

/**
 * @author yequan
 * @date 2021/03/26 15:07
 **/
public class LongUtil {

    public static void main(String[] args) {
//        Long id1 = 1L;
//        Long id2 = null;
//        Long id3 = 3L;
//
//        Long mId=1L;
//        System.out.println(mId.equals(id2));
//        System.out.println(mId==id2);
//
//        System.out.println(getInterMultiRideNum(id1, id2, id3));


        Long id1 = 1L;
        Long id2 = 4L;
        Long id3 = 3L;

        System.out.println(getCacheKey(8080, id1, id2, id3));
    }

    public static int getInterMultiRideNum(Long rideId1, Long rideId2, Long rideId3) {
        int rideNum = 0;
        if (null != rideId1) {
            rideNum++;
        }
        if (null != rideId2) {
            rideNum++;
        }
        if (null != rideId3) {
            rideNum++;
        }
        return rideNum;
    }

    public static String getCacheKey(Integer userId, long rideId1, long rideId2, long rideId3) {
        //升排序，保证同一个城际拼单不受订单顺序影响
        long[] rideIds = new long[3];
        rideIds[0] = rideId1;
        rideIds[1] = rideId2;
        rideIds[2] = rideId3;
        Arrays.sort(rideIds);
        return String.format("%s-%s-%s-%s", userId, rideIds[0], rideIds[1], rideIds[2]);
    }

}
